package com.tlgen.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import com.j256.ormlite.stmt.query.In;
import com.tlgen.R;
import com.tlgen.data.ContentPage;
import com.tlgen.fragment.CertificateFragment;
import com.tlgen.fragment.HouseholdFragment;
import com.tlgen.fragment.IdCardFragment;
import com.tlgen.fragment.LetterFragment;
import com.tlgen.fragment.TestPageFragment;
import com.xuexiang.xui.adapter.FragmentAdapter;
import com.xuexiang.xui.widget.actionbar.TitleBar;
import com.xuexiang.xui.widget.tabbar.EasyIndicator;

import java.util.ArrayList;
import java.util.List;

public class FileActivity extends AppCompatActivity {

    EasyIndicator mEasyIndicator;
    ViewPager mViewPager;
    TitleBar mTitleBar;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_file);
        mEasyIndicator = findViewById(R.id.easy_indicator);
        mViewPager = findViewById(R.id.view_pager);

        mTitleBar = findViewById(R.id.file_titlebar);
        mTitleBar.setLeftClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(FileActivity.this, MainActivity.class));
            }
        });

        List<Fragment> list = new ArrayList<>();
        String[] pages = ContentPage.getPageNames();
        for (String page : pages) {
            list.add(IdCardFragment.newInstance(page));
            list.add(HouseholdFragment.newInstance(page));
            list.add(LetterFragment.newInstance(page));
            list.add(CertificateFragment.newInstance(page));
        }

        mEasyIndicator.setTabTitles(ContentPage.getPageNames());
        mEasyIndicator.setViewPager(mViewPager, new FragmentAdapter<>(getSupportFragmentManager(), list));
        mViewPager.setOffscreenPageLimit(ContentPage.size() - 1);
    }

  /*  @Override
    protected void onDestroy() {
        super.onDestroy();
    }
*/
}
